//
//  UIView+Frame.m
//  NaoXinFaWu
//
//  Created by linzhijun on 16/5/26.
//  Copyright © 2016年 naoxin_Ltd. All rights reserved.
#import "UIView+Frame.h"

@implementation UIView (Frame)
- (void)setNx_x:(CGFloat)nx_x
{
    CGRect frame = self.frame;
    frame.origin.x = nx_x;
    self.frame = frame;
}

- (CGFloat)nx_x
{
    return self.frame.origin.x;
}

- (void)setNx_y:(CGFloat)nx_y
{
    CGRect frame = self.frame;
    frame.origin.y = nx_y;
    self.frame = frame;
}

- (CGFloat)nx_y
{
    return self.frame.origin.y;
}

- (void)setNx_width:(CGFloat)nx_width
{
    CGRect frame = self.frame;
    frame.size.width = nx_width;
    self.frame = frame;
    
}

- (CGFloat)nx_width
{
    return self.frame.size.width;
}

- (void)setNx_height:(CGFloat)nx_height
{
    CGRect frame = self.frame;
    frame.size.height = nx_height;
    self.frame = frame;
}

- (CGFloat)nx_height
{
    return self.frame.size.height;
}

- (void)setNx_size:(CGSize)nx_size
{
    CGRect frame = self.frame;
    frame.size = nx_size;
    self.frame = frame;
}

- (CGSize)nx_size
{
    return self.frame.size;
}

- (void)setNx_origin:(CGPoint)nx_origin
{
    CGRect frame = self.frame;
    frame.origin = nx_origin;
    self.frame = frame;
}

- (CGPoint)nx_origin
{
    return self.frame.origin;
}


-(void)setNx_centerX:(CGFloat)nx_centerX
{
    CGPoint center =self.center;
    center.x = nx_centerX;
    self.center = center;
    
}
-(CGFloat)nx_centerX
{
    return self.center.x;
}

-(void)setNx_centerY:(CGFloat)nx_centerY
{
    CGPoint center=self.center;
    center.y=nx_centerY;
    self.center=center;
}
-(CGFloat)nx_centerY
{
    return self.center.y;
}

-(BOOL)nx_intersectWithView:(UIView *)view
{
    if (view==nil) {
        view=[UIApplication sharedApplication].keyWindow;
    }
    CGRect rect1=[self convertRect:self.bounds toView:nil];
    CGRect rect2=[view convertRect:view.bounds toView:nil];
    return  CGRectIntersectsRect(rect1, rect2);
}
@end
